<template>
	<view class="msg">
		<view class="main">
			<view v-for="(item, index) in initData" :key="index">
					<view v-for="(item1, index1) in noreadtype" :key="index1">
			<view class="list" v-if="item1.msgType==item.id&&item.id==1" @click="go_type(1)">
				<image src="/static/img/msg1.png" />
				{{item.typeName}}
				<text class="right">
					<text class="message">{{item1.noreadnum}}</text>
					<uni-icons type="arrowright" size="24" color="#999" />
				</text>
			</view>
			<view class="list" v-if="item1.msgType==item.id&&item.id==2"  @click="go_type(2)">
				<image src="/static/img/msg2.png" />
				{{item.typeName}}
				<text class="right">
					<text class="message">{{item1.noreadnum}}</text>
					<uni-icons type="arrowright" size="24" color="#999" />
				</text>
			</view>
			<view class="list" v-if="item1.msgType==item.id&&item.id==3"  @click="go_type(3)">
				<image src="/static/img/msg3.png" />
				{{item.typeName}}
				<text class="right">
					<text class="message">{{item1.noreadnum}}</text>
					<uni-icons type="arrowright" size="24" color="#999" />
				</text>
			</view>
			</view>
			</view>
		</view>
	</view>
</template>
<script>
import { uniIcons } from '@dcloudio/uni-ui';
import msg from '../../../servers/my/msg.js';
export default {
	components: { uniIcons },
	data() {
		return {
			msg_list: [
				{
					id: 5,
					checked: false
				}
			],
			compile: false,
			initData:[],
			noreadtype:[],
			is_go_top: false,
			is_all: false
		};
	},
	mounted() {
		this.getData();
	},
	methods: {
		getData() {
			msg.initData()
				.then(res => {
					this.initData = res.data;
					msg.noReadByType()
						.then(res => {
							this.noreadtype=res.data;
						})
						.catch(err => {
							console.log(new Error('请检查网络后重试'));
						});
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
		},
		go_type(e){
			this.commonality.route_baling('/pages/shop/my/msglist','news_msglist',e)
		}
	}
};
</script>
<style lang="less" scoped>
.msg {
	.main {
		background: #fff;
		.list {
			position: relative;
			padding: 29rpx 20rpx 20rpx 134rpx;
			border-bottom: 1rpx solid #e1e1e1; /*no*/
			line-height: 90rpx;
			font-size: 30rpx;
			image {
				position: absolute;
				width: 90rpx;
				height: 90rpx;
				left: 20rpx;
			}
			.right {
				color: #999999;
				.message {
					display: inline-block;
					width: 40rpx;
					height: 40rpx;
					background: #bd3c8c;
					text-align: center;
					line-height: 40rpx;
					border-radius: 50%;
					font-size: 28rpx;
					color: #fff;
					margin-right: 12rpx;
				}
			}
		}
		.list:nth-last-child(1) {
			border-bottom: none;
		}
	}
}
</style>
